<?php
class Profile extends AppModel {

	var $name = 'Profile';
	var $useDbConfig = 'users';
	var $primaryKey = 'id';

	var $validate = array(
		'icq'=>array(
			'rule'=>'numeric',
			'allowEmpty' => true,
			'message'=>'numertic only'
		),
		'jabber'=>array(
			'rule'=>'email',
			'allowEmpty' => true,
			'message'=>'jabber format only'
		),
		'pubmail'=>array(
			'rule'=>'email',
			'allowEmpty' => true,
			'message'=>'mail format only'
		)

	);

	//The Associations below have been created with all possible keys, those that are not needed can be removed
	var $belongsTo = array(
			'City' => array('className' => 'City',
								'foreignKey' => 'city_id',
								'conditions' => '',
								'fields' => '',
								'order' => ''
			),
	);

	function getData($uid = null) {
		$c = array('user_id'=>$uid);
		if (!$this->hasAny($c)) {
			$this->save($c);
		}
		
		return $this->find('first', array('conditions'=>array('user_id'=>$uid)));
	}

	function getProfileID($uid = null) {
		return $this->field('id', array('user_id'=>$uid));
	}

}
?>
